<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
{{assign var="title" value='表单验证'}}
{{assign var="app" value='verify'}}
{{assign var="act" value=''}}
<title>{{$title}}{{$text}} - {{'admin|admin_site_name'|C|default:'后台管理'}}</title>
{{include file="include/base.html"}}
{{include file="{{$smarty.const.PLUG}}chosen/chosen.html"}}
{{include file="{{$smarty.const.PLUG}}drag/drag.html"}}
<script>
	$(document).ready(function(){
		//加载控件类型的附加参数
		$.post('{{"index.php?app=form&act=widget_type_change_ajax"|URL}}',{type:$('select.widget_type_change option:selected').val(), id:$('select.widget_type_change').attr('lang')},function(xml){
			if(!xml)
				$('.widget_type_tr').hide();
			else{
				$('.widget_type_td').html(xml);
				$('.widget_type_tr').fadeIn();
			}
		});
		//选择控件类型时->加载附加参数
		$('.tr_html').on('change','select.widget_type_change',function(){
			$.post('{{"index.php?app=form&act=widget_type_change_ajax"|URL}}',{type:$(this).val(), id:$(this).attr('lang')},function(xml){
				if(!xml)
					$('.widget_type_tr').hide();
				else{
					$('.widget_type_td').html(xml);
					$('.widget_type_tr').fadeIn();
				}
			});
		});
		//控件类型为:select_db 数据库下拉列表onchange触发时
		$('.tr_html').on('change','select[name="param[params][select_db_table]"]',function(){
			//key
			$.post('{{"index.php?app=form&act=dbname2fields"|URL}}',{table:$(this).val(), name:'param[params][select_db_key]', id:$('select.widget_type_change').attr('lang')},function(xml){
				$('.param_params_select_db_key').html(xml);
			});
			//value
			$.post('{{"index.php?app=form&act=dbname2fields"|URL}}',{table:$(this).val(), name:'param[params][select_db_value]', id:$('select.widget_type_change').attr('lang')},function(xml){
				$('.param_params_select_db_value').html(xml);
			});
		});
	});

//添加自定义字段时
function get_tr(){
	$.post('{{"index.php?app=form&act=verify_detail_tr_ajax"|URL}}',{ field_name:$('.add_field_name').val(),cat_id:{{$smarty.get.cat_id}} },function(xml){
		if(xml){
			$('table td.tr_html').append(xml);
			$('form.form').fadeIn();
			$('span.field_name').html($('.add_field_name').val());
			$(".chosen").chosen({no_results_text: "没有找到: "});
		}else{
			parent.ui.alert('字段名有误!');
		}
	});
}
</script>
</head>
<body>

	<div class="body_right">
	<div id="content">
	
	<div class="search">
	  <ul class="bread">
		<li>
			◆ 表名：table 　　
			字段名：
			<span class="field_name">
			{{if $smarty.get.field_name!=''}}
				{{$smarty.get.field_name}}
			{{else}}
				<script>$(function(){ $('form.form').hide(); });</script>
				<input onKeyDown="if(event.keyCode==13) get_tr()" placeholder="只能字母开头(字母/下划线/数字)" type="text" class="add_field_name" value=""/>
				<button class="btn get_tr" onClick="get_tr()">开始</button>
			{{/if}}
			</span>
		</li>
	  <ul>
	</div>
			
		<!--内容 S-->
		<form action="index.php?app=form&act=save" name="form" class="form ajaxSubmit" id="form" method="post">
		<input type="hidden" name="id" value="{{$smarty.get.id}}"/>
		<input type="hidden" name="cat_id" value="{{$smarty.get.cat_id}}"/>
		<input type="hidden" name="is_custom" value="{{if $smarty.get.is_custom}}1{{/if}}"/>
		<table class="table table-bordered modify">

			<tbody class="tbody">
			<tr>
				<td class="tr_html">
				{{$tr_html}}
				</td>
			</tr>
			</tbody>
		 </table>
		<div class="bottom_button">
			<button type="submit" class="btn btn-info"><i class="icon-ok icon-white"></i>确认</button>
		</div>
		</form>
		<!--内容 E-->
		
	</div>
</div>
<style>
.body_right{top:0 !important;}
</style>

</body>
</html>